package com.groupseven.happycampus.common.instener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.groupseven.happycampus.common.bo.BicycleOrderBo;
import com.groupseven.happycampus.common.pojo.BicycleOrder;
import com.groupseven.happycampus.service.BicycleOrderService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope("prototype")     // 注意 这里要设置成多例模式
public class WebOrderListener extends AnalysisEventListener<BicycleOrderBo> {

    @Autowired
    BicycleOrderService bicycleOrderService;



    @Override
    public void invoke(BicycleOrderBo data, AnalysisContext analysisContext) {
        BicycleOrder bicycleOrder = new BicycleOrder();
        BeanUtils.copyProperties(data,bicycleOrder);
        bicycleOrderService.bicycleOrderAdd(bicycleOrder);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
